import base from './src/main';
export default {
	install(wf) {
		// 加载云开发
		const cloud = tcb.init({
			env: 'winfyho-cloud-0gfbcdsg0e062644', // 此处填入您的环境ID
		});

		// 初始化cloudApi
		const cloudApi = {};
		const apiMap = base.api;

		Object.keys(apiMap).forEach((funcName) => {
			const func = apiMap[funcName];
			cloudApi[funcName] = func.bind(cloud);
		});

		// 添加模块
		wf.addModule('cloud', cloud);
		wf.addModule('cloudApi', cloudApi);

		// 测试代码
		cloud
			.auth()
			.signInAnonymously()
			.then(() => {
				console.log('登录云开发成功！', cloudApi);
				// cloudApi.getUserInfo().then((res) => {
				// 	console.log('getUserInfo', res.data);
				// });
			});
	},
};
